package com.guangyunl.d_array;
// 获取二维数组中的元素
public class Demo01Array {
    public static void main(String[] args){
    String[][] arr1={
        {"孙悟空","唐僧"},
        {"刘备","关羽","张飞"},
        {"宋江"},
        {"林黛玉","贾宝玉"}
    };

        System.out.println("========================");

        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr1[i].length; j++) {
                System.out.print("arr1["+ i +"][" + j + "] = " + arr1[i][j]);
                System.out.print("  ");
            }
            System.out.println();
        }

        System.out.println("========================");

        System.out.println("arr1[0][0] = " + arr1[0][0]);
        System.out.println("arr1[2][0] = " + arr1[2][0]);
        System.out.println("arr1[3][1] = " + arr1[3][1]);
    }
}

/*
========================
arr1[0][0] = 孙悟空  arr1[0][1] = 唐僧
arr1[1][0] = 刘备  arr1[1][1] = 关羽  arr1[1][2] = 张飞
arr1[2][0] = 宋江
arr1[3][0] = 林黛玉  arr1[3][1] = 贾宝玉
========================
arr1[0][0] = 孙悟空
arr1[2][0] = 宋江
arr1[3][1] = 贾宝玉
 */